function publisher() {
  this.object = {}
  //订阅函数
  this.on = function (type, fn) {
    if (!this.object[type]) {
      this.object[type] = []
    }
    this.object[type].push(fn)
  }
  //删除函数
  this.off = function (type, fn) {
    let arr = []
    for (i = 0; i < this.object[type].length; i++) {
      if (this.object[type][i] !== fn) {
        arr.push(this.object[type][i])
      }
    }
    this.object[type] = arr
  }
  //发布函数
  this.publish = function (type, ...args) {
    this.object[type].forEach(v => {
      v(...args
      )
    })
  }
}
let jack = new publisher()
let tom = {
  read: function (info) {
    console.log(info)
  }
}
jack.on("书籍",tom.read)
jack.on("体育",tom.read)
jack.off('体育',tom.read)
jack.publish("书籍","斗罗大陆上线了")
jack.publish("体育","皇马绝杀")